<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Risultato ricerca</title>
</head>
<body>
	<p>
		<a href="ProfiloAmmServlet?id=<%= request.getAttribute("user") %>"><%= request.getAttribute("user") %></a>
		<a href="RicercaAmm.jsp?id=<%= request.getAttribute("user") %>">Ricerca</a> 
		<a href="LogoutServlet?username=<%= request.getAttribute("user")%>&user=amministratore">Logout</a>
	</p>
	<% 
    int size = Integer.parseInt(request.getAttribute("size").toString());
	
	if(size == 0) {
		
		out.println(request.getAttribute("msg"));
		
	}
	else {
		
		String id = request.getAttribute("user").toString();
		
		if(request.getAttribute("tipo").toString().equals("nome")) {
			   
			   String nome = new String();
			   String cognome = new String();
			   String username = new String();
			   out.println("<ul>");
	           for(int i = 0; i < size; i++) {
				   
	        	   out.println("<li>");
				   nome = request.getAttribute("nome" + i).toString();
				   cognome = request.getAttribute("cognome" + i).toString();
				   username = request.getAttribute("username" + i).toString();
				   out.println(nome);
				   out.println(cognome);
				   out.println(" (");
				   out.println("<a href=\"ProfiloUtenteDaAmmServlet?username=" + request.getAttribute("username" + i) + "&id=" + id + "\">");
				   out.println(username);
				   out.println("</a>");
				   out.println(")");
				   out.println("</li>");
				   out.println("<br/>");
				   
			  }
	          out.println("</ul>");
			   
	   }
		   
	   else if(request.getAttribute("tipo").toString().equals("username")) {
			   			   
			   String username = request.getAttribute("username").toString();
			   String nome = request.getAttribute("nome").toString();
			   String cognome = request.getAttribute("cognome").toString();
			   out.println(nome);
			   out.println(cognome);
			   out.println(" (");
			   out.println("<a href=\"ProfiloUtenteDaAmmServlet?username=" + username + "&id=" + id + "\">");
			   out.println(username);
			   out.println("</a>");
			   out.println(")");
			   out.println("</li>");
			   out.println("<br/>");
			   
	  }
		   
	  else if(request.getAttribute("tipo").toString().equals("abilita")) {
			   
			   String nome = new String();
			   String cognome = new String();
			   String username = new String();
			   out.println("<ul>");
	           for(int i = 0; i < size; i++) {
	        	   
	        	   out.println("<li>");
				   nome = request.getAttribute("nome" + i).toString();
				   cognome = request.getAttribute("cognome" + i).toString();
				   username = request.getAttribute("username" + i).toString();
				   out.println(nome);
				   out.println(cognome);
				   out.println(" (");
				   out.println("<a href=\"ProfiloUtenteDaAmmServlet?username=" + request.getAttribute("username" + i) + "&id=" + id + "\">");
				   out.println(username);
				   out.println("</a>");
				   out.println(")");
				   out.println("</li>");
				   out.println("<br/>");
				   
			   }
	           out.println("</ul>");
			   
	    }
		
	}
%>
</body>
</html>